package com.ymttest.database.sqlwapper.shenqisettlement;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.shenqisettlement.DistributorProductDetail;

public class DistributorProductDetailWrapper {

	SqlManager manager;

	public DistributorProductDetailWrapper() {
		manager = new SqlManager("shenqisettlement");
	}

	@SuppressWarnings("unchecked")
	public DistributorProductDetail selectByPrimaryKey(long id) {

		DistributorProductDetail distributorProductDetail = new DistributorProductDetail();
		List<DistributorProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.DistributorProductDetailMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			distributorProductDetail = result.get(0);
		}

		return distributorProductDetail;
	}
	
	@SuppressWarnings("unchecked")
	public DistributorProductDetail selectByOrderIdAndDistributorIdAndCatalogId(
			long orderId, Long distributorId, String catalogId, Integer partnerType) {

		HashMap<String, Object> map = new HashMap<>();

		map.put("order_id", orderId);
		map.put("distributor_id", distributorId);
		map.put("catalog_id", catalogId);
		map.put("partner_type", partnerType);

		DistributorProductDetail distributorProductDetail = new DistributorProductDetail();
		List<DistributorProductDetail> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.shenqisettlement.DistributorProductDetailMapper.selectByOrderIdAndDistributorIdAndCatalogId",
						map);
		manager.commit();

		if (result.size() > 0) {
			distributorProductDetail = result.get(0);
		}

		return distributorProductDetail;
	}
	
	public static void main(String[] args) {
		
		DistributorProductDetailWrapper wrapper = new DistributorProductDetailWrapper();
		
		System.out.println(wrapper.selectByPrimaryKey(1));
	}
}
